<script>
function setFocus(){
	$('identity').focus()
}

window.addEvent('load', function(){		
	//setFocus();
	
	new DatePicker('.demo_noyear', { 
		pickerClass: 'datepicker_vista', 
		yearPicker:	true,
		format: 'Y-m-d' ,
		allowEmpty: true,
		startView:'decades',
	});
	
        new FormCheck('member_edit', {
		display : {
			errorsLocation : 1,
			showErrors : 1,
			addClassErrorToField : 1
		}
	})
});

</script>
<?php $id = $this->uri->segment(3,0)?>
<form action="<?php echo site_url(array('just4u','member_update',$id))?>" method="post" enctype="multipart/form-data" name="member_edit" id="member_edit">
<?php 
$name = "";
$place = "";
$birthday = "";
$address = "";
$phone1 = "";
$phone2 = "";
$email1 = "";
$email2 = "";
$website = "";
$gender = "";
foreach ($query->result() as $row):
	if($row->images_type=="" || $row->images_type==NULL){
		$images = site_url("images/noimages.jpg");
	} else {
		$images = site_url(array('just4u','ImagesMedium','member',$row->id_member));
	}
	
	$que = $this->db->query("select * from contact_member where member='$row->id_member' limit 1");
		foreach ($que->result() as $res):
				$address = $res->address;
				$phone1 = $res->phone1;
				$phone2 = $res->phone2;
				$email1 = $res->email1;
				$email2 = $res->email2;
				$website = $res->website;
		endforeach;
		
		$q = $this->db->query("select * from info_member where member='$row->id_member' limit 1");
		foreach ($q->result() as $re):
				$name = $re->name;
				$birthday = $re->birthday;
				$place = $re->place_of_birth;
				$gender = $re->gender;
		endforeach;
	
?>
<table width="0%" border="0" cellspacing="2" cellpadding="3">
  <tr>
  	<td valign="top"><img src="<?php echo $images?>" /></td>
    <td align="right" valign="top"><table width="0" border="0" cellspacing="2" cellpadding="3">
      <tr>
        <th align="right" scope="row">Name</th>
        <td><input name="name" type="text" id="name" size="30" maxlength="100" class="validate['required']" value="<?php echo $name ?>" /></td>
      </tr>
      <tr>
        <th align="right" scope="row">Birthday</th>
        <td><input placeholder="Place" name="place_of_birth" type="text" class="validate['required']" id="place_of_birth" size="17" maxlength="45" value="<?php echo $place?>" />
        <?php echo $birthday?>
          <input name="birthday" type="text" id="birthday" class="date demo_noyear" size="15" /></td>
      </tr>
      <tr>
        <th align="right" scope="row">Gender</th>
        <td>
        <input type="radio" name="gender" id="radio5" value="Male" class="validate['required']" <?php if($gender=="Male"){echo "checked='checked'";}?> />
          Male
          <input type="radio" name="gender" id="radio6" value="Female" class="validate['required']" <?php if($gender=="Female"){echo "checked='checked'";}?> />
          Female</td>
      </tr>
      <tr>
        <th align="right" scope="row">Address</th>
        <td><input name="address" type="text" id="address" size="40" maxlength="200" class="validate['required']" value="<?php echo $address?>" /></td>
      </tr>
      <tr>
        <th align="right" valign="top" scope="row">Phone</th>
        <td><input placeholder="Phone1" name="phone1" type="text" id="phone1" size="20" maxlength="45" class="validate['required','phone']" value="<?php echo $phone1?>" />
          <br />
          <input placeholder="Phone2" name="phone2" type="text" id="phone2" size="20" maxlength="45" class="validate['phone']" value="<?php echo $phone2?>" /></td>
      </tr>
      <tr>
        <th align="right" valign="top" scope="row">Email</th>
        <td><input placeholder="Email1" name="email1" type="text" id="email1" size="28" maxlength="150" class="validate['required','email']" value="<?php echo $email1?>" />
          <br />
          <input placeholder="Email2" name="email2" type="text" id="email2" size="28" maxlength="150" class="validate['email']" value="<?php echo $email2?>" /></td>
      </tr>
      <tr>
        <th align="right" scope="row">Website</th>
        <td><input name="website" type="text" id="website" size="35" maxlength="100" class="validate['url']" value="<?php echo $website?>" /></td>
      </tr>
    </table></td>
    <td valign="top"><table width="0%" border="0" cellspacing="2" cellpadding="3">
      <tr>
        <th align="right">Username</th>
        <td><?php echo $row->username?></td>
      </tr>
      <tr>
        <th align="right">Password</th>
        <td><?php echo $row->password?></td>
      </tr>
      <tr>
        <th align="right">Images</th>
        <td><label for="images"></label>
          <input type="file" name="images" id="images" /></td>
      </tr>
      <tr>
        <th align="right" valign="top">Type </th>
        <td valign="top"><input type="radio" name="type" id="radio" value="admin" <?php if($row->type=="admin"){echo "checked='checked'";}?> />
          Admin
          <input name="type" type="radio" id="radio2" value="user" <?php if($row->type=="user"){echo "checked='checked'";}?> />
          User</td>
      </tr>
      <tr>
        <th align="right" valign="top">Status</th>
        <td align="left"><input name="status" type="radio" id="radio3" value="active" <?php if($row->status=="active"){echo "checked='checked'";}?> />
          Active
          <input name="status" type="radio" id="radio4" value="deactive" <?php if($row->status=="deactive"){echo "checked='checked'";}?> />
          Deactive</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td></td>
    <td align="right" valign="top">&nbsp;</td>
    <td align="right"><input type="reset" name="button2" id="button2" value="Reset" class="uiButtonRounded" />
      <input type="submit" name="button" id="button" value="Save" class="uiButtonRounded" /></td>
  </tr>
</table>
<?php endforeach;?>
</form>